﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Configuration;
using PWS.Entities;

namespace PWS.DAL
{
    public class SuitsAccess
    {
        private static Suits SuitsFields(DataRow Row)
        {
            Suits s = new Suits();
            s.SuitId = (int)Row["fldSuitId"];
            s.SuitName = Row["fldSuitName"] as string;
           
            s.SuitPrice = (decimal)Row["fldSuitPrice"];
            return s;
        }
        private static Suits[] DataSetToSuitsArray(DataSet ds2)
        {
            Suits[] suits = new Suits[ds2.Tables[0].Rows.Count];
            for( int i=0; i < ds2.Tables[0].Rows.Count; ++i)
            {
                suits[i] = SuitsFields(ds2.Tables[0].Rows[i]);
              
            }
            return suits;
        }
        public static Suits[] GetSuits()
        {
            DataSet ds2 = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["PineDb"].ConnectionString, "Suits_Get_Suits");
            return DataSetToSuitsArray(ds2);
        }

    }
}
